import ajax from '@/utils/request.js'

// 发表文章
function addArticles (data, params) {
  return ajax({
    url: '/mp/v1_0/articles',
    method: 'post',
    data,
    params
  })
}
// 获取频道
function getChannel (params) {
  return ajax({
    url: '/mp/v1_0/channels',
    method: 'get',
    params
  })
}
// 获取全部图片
function getImages (params) {
  return ajax({
    url: '/mp/v1_0/user/images',
    method: 'get',
    params
  })
}
// 获取指定文章
function getArticle (params) {
  const { id } = params
  return ajax({
    url: `/mp/v1_0/articles/${id}`,
    method: 'get',
    params
  })
}
// 编辑文章
function editArticle (data) {
  const { id } = data
  return ajax({
    url: `/mp/v1_0/articles/${id}`,
    method: 'put',
    data
  })
}

export { addArticles, getChannel, getImages, getArticle, editArticle }
